﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class StartMenuUI : MonoBehaviour {



    public void StartButtonClick()
    {
        Debug.Log("游戏开始");
        SceneManager.LoadSceneAsync(1);
        transform.Find("Button").gameObject.SetActive(false);
        transform.Find("Text").gameObject.SetActive(false);
        transform.Find("Image").gameObject.SetActive(false);
        transform.Find("Image2").gameObject.SetActive(false);
        transform.Find("LOAD").gameObject.SetActive(true);
    }




    private List<Transform> UIlist = new List<Transform>();
    private List<Vector2> UIposList = new List<Vector2>();
    private void Start()
    {
        int c = transform.childCount;
        for(int i = 0; i < c; i++)
        {
            Transform t = transform.GetChild(i);
            UIlist.Add(t);
            UIposList.Add(t.position);
        }
        Transform tt = transform.Find("Button");
        offset=Camera.main.ScreenPointToRay(tt.position).origin;
        AudioController.Play("BGM");
    }


    Vector2 offset;
    Vector2 mousePosition;
    private void Update()
    {
        mousePosition= (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition)-offset;
        for(int i = 0; i < UIlist.Count; i++)
        {
            UIlist[i].position = UIposList[i] + mousePosition * 4* ((i-1)+0.1f);
        }
    }

}
